﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace XhPaper
{
    public class XhEntityClass:MyObjectBase
    {
        public int index;
        public CadText m_xhName;
        public CadText[] m_CaiJiPosition1;
        public CadText m_outName;
        public CadText m_outPosition;
        public XhEntityClass()
        {
            m_xhName = new CadText();
            m_CaiJiPosition1 = new CadText[2];
            m_outName = new CadText();
            m_outPosition = new CadText();
        }
    }

    public class JieKouEntityClass : MyObjectBase
    {
        public CadText m_JieKouBoardName;
        public CadText m_textposition;
        public XhEntityClass[] m_xhEntity;
        public CadText m_workPower;
        public JieKouEntityClass()
        {
            m_JieKouBoardName = new CadText();
            m_textposition = new CadText();
            m_xhEntity = new XhEntityClass[2];
            m_workPower = new CadText();
        }
    }

    public class JieKouBoardClass : MyObjectBase
    {
        public StructClass m_JieKouBoardStruct;
        public List<JieKouEntityClass> m_JieKouEntity;
        public List<CadText> m_propertylst;
        XmlDocument xmlDoc;
        public JieKouBoardClass()
        {
            m_JieKouBoardStruct=new StructClass();
            m_JieKouEntity = new List<JieKouEntityClass>();
            m_propertylst = new List<CadText>();
            xmlDoc = new XmlDocument();
            string filename = System.IO.Directory.GetCurrentDirectory() + "\\jkbXMLFile1.xml";
            xmlDoc.Load(filename);
        }
        public void CreateJieKouEntity()
        {

        }
        public void CreateJieKouBoardStruct()
        {
            if (m_JieKouBoardStruct == null)
            {
                m_JieKouBoardStruct = new StructClass();
                XmlElement root = xmlDoc.DocumentElement;
                #region 得到粗线条
                double bottom, left, width, heigh;
                XmlNodeList nodeList = root.SelectNodes("RECT");
                if (nodeList.Count > 0)
                {
                    double.TryParse(nodeList.Item(0).Attributes["Bottom"].Value, out bottom);
                    double.TryParse(nodeList.Item(0).Attributes["Left"].Value, out left);
                    double.TryParse(nodeList.Item(0).Attributes["WIDTH"].Value, out width);
                    double.TryParse(nodeList.Item(0).Attributes["HEIGHT"].Value, out heigh);
                    m_JieKouBoardStruct.AddLine(new double[] { left, bottom, 0 }, new double[] { left, bottom + heigh, 0 },true);
                    m_JieKouBoardStruct.AddLine(new double[] { left + width, bottom, 0 }, new double[] { left + width, bottom + heigh, 0 },true);
                    m_JieKouBoardStruct.AddLine(new double[] { left, bottom, 0 }, new double[] { left + width, bottom, 0 },true);
                    m_JieKouBoardStruct.AddLine(new double[] { left, bottom + heigh, 0 }, new double[] { left + width, bottom + heigh, 0 },true);
                }
                nodeList = root.SelectNodes("WHang3");
                double startx, endx;
                double[] y;
                if (nodeList.Count > 0)
                {
                     y=MyCommonMethod.GetDoubles(nodeList.Item(0).Attributes["Y"].Value);
                     double.TryParse(nodeList.Item(0).Attributes["StartX"].Value, out startx);
                     double.TryParse(nodeList.Item(0).Attributes["EndX"].Value, out endx);
                     foreach (double d in y)
                     {
                         m_JieKouBoardStruct.AddLine(new double[] { startx,d ,0 }, new double[] { endx,d, 0 }, true);
                     }
                }
                #endregion
            }
        }
        public void CreateOtherProperty()
        {

        }

    }
}
